const express = require('express');
const cookie = require('cookie-parser');


let app = express();
app.use(cookie('admin'));
app.get('/set', function (req, res) {
    res.cookie('a', 1);
    res.cookie('b', 2, {maxAge: 6*1000});
    res.cookie('c', 3, {signed: true});
    res.cookie('d', 4);
    res.send('set成功');
});

app.get('/get', function (req, res) {
    console.log('未加密：'+ req.cookies.a);
    console.log('未加密：'+ req.cookies.b);
    console.log('未加密：'+ req.cookies.c);
    console.log('未加密：'+ req.cookies.d);
    console.log('加密：'+ req.signedCookies.c);
    res.send('get成功');
});

app.get('/del',function (req, res) {
    res.clearCookie('a');
    res.end('ddddddddd');
});
app.listen(8080);